import React from 'react'
import styles from './index.less'
import defaultBicycle from './img/default.png'
import logoGiant from '../../assets/bicycleLogo/giant.png'
import { useHistory } from 'dva'
import { GetFirstImg } from '../../utils/tools'
import { E } from '../../../../constants'
import { Currency } from '../../utils/utils';
import { getLocale } from 'umi';
function Index({ obj }) {
  const history = useHistory()
  function filterData() {
    let name = '';
    let img = '';
    let logo = '';
    let price = ''
    if (obj) {
      // console.log(obj);
      name = getLocale() == "zh-CN" ? obj.name : obj.nameEn;
      img = obj.properties ? obj.properties.albums[0] : '';
      logo = obj.exhibitor ? obj.exhibitor.properties.logo : '';
      price = obj?.currency? `${Currency[obj.currency].description}${obj.minimum ? obj.minimum : ''} ~ ${Currency[obj.currency].description}${obj.maximum ? obj.maximum : ''}`:''
   
    }
    return {
      name,
      img,
      logo,
      price
    }
  }
  let data = filterData()
  return (
    <div className={styles.box} onClick={() => { history.push(`/index/details/${obj && obj.id}`) }}>
      <div className={styles.imgBox}>
        <img src={data.img}></img>
      </div>
      <div className={styles.textBox}>
        <p className={styles.text}>{data.name}</p>
        <p className={styles.price}>{data.price}</p>
      </div>
    </div>
  )
}

export default Index
